package client;

import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;

import sharedspace.ExecuteTest;
import sharedspace.MyFile;
import sharedspace.Student;

import messages.MessageSendWordTest;

public class GetFileFromServer {
	private String path;
	
	public GetFileFromServer(String path)
	{
		this.path = path;
	}
	 public  void getFileFromServer(MyFile myFile) 
	 { 
		 
		 	
			try
			{	
				File file = new File(path+"\\"+myFile.getFileName());
				byte mybytearray[] = myFile.getMybytearray();
				BufferedOutputStream bos;
				bos = new BufferedOutputStream(new FileOutputStream(file));
				bos.write(mybytearray, 0 , mybytearray.length); //write out file
			    bos.flush(); //close buffer
			    bos.close();
			} 
			catch (FileNotFoundException e)
			{
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	 		catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
			
	      
	    } 

}
